container: Request layout again depending on layout mode
authorBenjamin Otte <otte@redhat.com>
Mon, 22 Feb 2016 20:38:03 +0000 (21:38 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 23 Feb 2016 03:22:19 +0000 (04:22 +0100)
Containers with RESIZE_MODE_PARENT should never request layout and those
with RESIZE_MODE_IMMEDIATE should only request it for updating CSS.

Fixes clutter embeds (like the tray icon embed in gnome-shell)
continuously requesting relayout when all they want to do is relegate
relayout to Clutter.

https://bugzilla.gnome.org/show_bug.cgi?id=758893

gtk/gtkcontainer.c

index 69ffbd7df17ba3b8f31b5f29bbfeb3b934598669..01dbbcb41e16033fccdc7e58977a794e0fe0951b 100644 (file)
@@ -2000,6 +2000,23 @@ gtk_container_set_reallocate_redraws (GtkContainer *container,
   container->priv->reallocate_redraws = needs_redraws ? TRUE : FALSE;
 }
 
+static gboolean
+gtk_container_needs_idle_sizer (GtkContainer *container)
+{
+  GtkContainerPrivate *priv = container->priv;
+
+  if (priv->resize_mode == GTK_RESIZE_PARENT)
+    return FALSE;
+
+  if (container->priv->restyle_pending)
+    return TRUE;
+
+  if (priv->resize_mode == GTK_RESIZE_IMMEDIATE)
+    return FALSE;
+
+  return gtk_widget_needs_allocate (GTK_WIDGET (container));
+}
+
 static void
 gtk_container_idle_sizer (GdkFrameClock *clock,
                          GtkContainer  *container)
@@ -2031,7 +2048,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
       gtk_container_check_resize (container);
     }
 
-  if (!container->priv->restyle_pending && !gtk_widget_needs_allocate (GTK_WIDGET (container)))
+  if (!gtk_container_needs_idle_sizer (container))
     {
       _gtk_container_stop_idle_sizer (container);
     }
@@ -2126,12 +2143,7 @@ _gtk_container_queue_restyle (GtkContainer *container)
 void
 _gtk_container_maybe_start_idle_sizer (GtkContainer *container)
 {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-  if (!GTK_IS_RESIZE_CONTAINER (container))
-    return;
-G_GNUC_END_IGNORE_DEPRECATIONS;
-
-  if (container->priv->restyle_pending || gtk_widget_needs_allocate (GTK_WIDGET (container)))
+  if (gtk_container_needs_idle_sizer (container))
     gtk_container_start_idle_sizer (container);
 }